﻿<Activity mc:Ignorable="sap" x:Class="Reactor.ServiceGrid.Workflows.AdoptServiceWorkflow" 
          xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" 
          xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
          xmlns:l="clr-namespace:log4net;assembly=log4net" 
          xmlns:lc="clr-namespace:log4net.Core;assembly=log4net" 
          xmlns:local="clr-namespace:Reactor.ServiceGrid.Workflows.Activities" 
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
          xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" 
          xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" 
          xmlns:re="clr-namespace:Reactor.Environment;assembly=Reactor" 
          xmlns:rm="clr-namespace:Reactor.Messages;assembly=Reactor.Messages" 
          xmlns:rm1="clr-namespace:Reactor.Messaging;assembly=Reactor" 
          xmlns:rs="clr-namespace:Reactor.ServiceGrid" 
          xmlns:rmea="clr-namespace:Reactor.Messages.Events.Adoptions;assembly=Reactor.Messages" 
          xmlns:rp="clr-namespace:Reactor.Providers;assembly=Reactor" 
          xmlns:rsp="clr-namespace:Reactor.ServiceGrid.Packages;assembly=Reactor" xmlns:rsr="clr-namespace:Reactor.ServiceGrid.Repositories;assembly=Reactor" xmlns:rst="clr-namespace:Reactor.ServiceGrid.Tools" xmlns:rwa="clr-namespace:Reactor.Workflow.Activities;assembly=Reactor" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:s4="clr-namespace:System;assembly=System.ComponentModel.Composition" xmlns:s5="clr-namespace:System;assembly=System.ServiceModel" xmlns:s6="clr-namespace:System;assembly=Reactor" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=Reactor" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=Samurai.Wakizashi" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg4="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg5="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ss="clr-namespace:System.ServiceProcess;assembly=System.ServiceProcess" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Members>
    <x:Property Name="ServiceIdentifier" Type="InArgument(rs:ServiceIdentifier)" />
  </x:Members>
  <sap:VirtualizedContainerService.HintSize>658,937</sap:VirtualizedContainerService.HintSize>
  <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>
  <Flowchart sad:XamlDebuggerXmlReader.FileName="C:\Projects\Reactor\Platform Source\trunk\Reactor.ServiceGrid\Reactor.ServiceGrid\Workflows\AdoptService.xaml" sap:VirtualizedContainerService.HintSize="618,897">
    <Flowchart.Variables>
      <Variable x:TypeArguments="s:Guid" Name="ServiceInstanceIdentifier" />
      <Variable x:TypeArguments="x:String" Name="ServiceExecutablePath" />
      <Variable x:TypeArguments="rmea:ServiceAdopted" Name="AdoptedEventMessage" />
      <Variable x:TypeArguments="x:Boolean" Default="[Reactor.ServiceGrid.Tools.ServiceInstaller.ServiceIsRunningLocally(ServiceIdentifier.ToServiceInstanceString())]" Name="ServiceExistsLocally" />
      <Variable x:TypeArguments="x:String" Name="DonorCoreName" />
      <Variable x:TypeArguments="scg5:IEnumerable(rm1:IMessagingChannel)" Name="AdoptedEventDestinations" />
    </Flowchart.Variables>
    <sap:WorkflowViewStateService.ViewState>
      <scg5:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">False</x:Boolean>
        <av:Point x:Key="ShapeLocation">270,2.5</av:Point>
        <av:Size x:Key="ShapeSize">60,75</av:Size>
        <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 300,115</av:PointCollection>
        <x:Double x:Key="Width">604</x:Double>
        <x:Double x:Key="Height">861</x:Double>
      </scg5:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <Flowchart.StartNode>
      <FlowStep x:Name="__ReferenceID2">
        <sap:WorkflowViewStateService.ViewState>
          <scg5:Dictionary x:TypeArguments="x:String, x:Object">
            <av:Point x:Key="ShapeLocation">191,115</av:Point>
            <av:Size x:Key="ShapeSize">218,130</av:Size>
            <av:PointCollection x:Key="ConnectorLocation">300,245 300,275 300,282.5</av:PointCollection>
          </scg5:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
        <InvokeMethod DisplayName="Associate Instance With Core" sap:VirtualizedContainerService.HintSize="218,130" MethodName="AssociateServiceInstanceWithCore">
          <InvokeMethod.Result>
            <OutArgument x:TypeArguments="s:Guid">[ServiceInstanceIdentifier]</OutArgument>
          </InvokeMethod.Result>
          <InvokeMethod.TargetObject>
            <InArgument x:TypeArguments="rp:ICoreDataProvider">[Context.GridContext.CoreDataProvider]</InArgument>
          </InvokeMethod.TargetObject>
          <InArgument x:TypeArguments="rs:ServiceIdentifier">[Reactor.Environment.Context.GridContext.CurrentReactorService.Identifier]</InArgument>
          <InArgument x:TypeArguments="rs:ServiceIdentifier">[ServiceIdentifier]</InArgument>
        </InvokeMethod>
        <FlowStep.Next>
          <FlowDecision x:Name="__ReferenceID3" Condition="[ServiceExistsLocally]" sap:VirtualizedContainerService.HintSize="60,75">
            <sap:WorkflowViewStateService.ViewState>
              <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                <av:Point x:Key="ShapeLocation">270,282.5</av:Point>
                <av:Size x:Key="ShapeSize">60,75</av:Size>
                <av:PointCollection x:Key="FalseConnector">330,320 430,320 430,460 400,460</av:PointCollection>
                <av:PointCollection x:Key="TrueConnector">270,320 130,320 130,379</av:PointCollection>
              </scg5:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <FlowDecision.True>
              <FlowStep x:Name="__ReferenceID6">
                <sap:WorkflowViewStateService.ViewState>
                  <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                    <av:Point x:Key="ShapeLocation">30,379</av:Point>
                    <av:Size x:Key="ShapeSize">200,22</av:Size>
                    <av:PointCollection x:Key="ConnectorLocation">130,401 130,460 200,460</av:PointCollection>
                  </scg5:Dictionary>
                </sap:WorkflowViewStateService.ViewState>
                <local:ShutdownWindowsService DisplayName="Stop Windows Service" sap:VirtualizedContainerService.HintSize="200,22" ServiceIdentifier="[ServiceIdentifier]" />
                <FlowStep.Next>
                  <FlowStep x:Name="__ReferenceID1">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                        <av:Point x:Key="ShapeLocation">200,449</av:Point>
                        <av:Size x:Key="ShapeSize">200,22</av:Size>
                        <av:PointCollection x:Key="ConnectorLocation">300,471 300,501 300,502.5</av:PointCollection>
                      </scg5:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                    <local:InstallServicePackage DisplayName="Install Service Package" sap:VirtualizedContainerService.HintSize="200,22" ServiceExecutablePath="[ServiceExecutablePath]" ServiceIdentifier="[ServiceIdentifier]" ServiceInstanceIdentifier="[ServiceInstanceIdentifier]" />
                    <FlowStep.Next>
                      <FlowDecision x:Name="__ReferenceID7" Condition="[ServiceExistsLocally]" sap:VirtualizedContainerService.HintSize="60,75">
                        <sap:WorkflowViewStateService.ViewState>
                          <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                            <av:Point x:Key="ShapeLocation">270,502.5</av:Point>
                            <av:Size x:Key="ShapeSize">60,75</av:Size>
                            <av:PointCollection x:Key="FalseConnector">330,540 430,540 430,619</av:PointCollection>
                            <av:PointCollection x:Key="TrueConnector">270,540 170,540 170,720 200,720</av:PointCollection>
                          </scg5:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                        <FlowDecision.True>
                          <FlowStep x:Name="__ReferenceID0">
                            <sap:WorkflowViewStateService.ViewState>
                              <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                                <av:Point x:Key="ShapeLocation">200,709</av:Point>
                                <av:Size x:Key="ShapeSize">200,22</av:Size>
                                <av:PointCollection x:Key="ConnectorLocation">300,731 300,761 300,789</av:PointCollection>
                              </scg5:Dictionary>
                            </sap:WorkflowViewStateService.ViewState>
                            <local:StartWindowsService sap:VirtualizedContainerService.HintSize="200,22" ServiceIdentifier="[ServiceIdentifier]" />
                            <FlowStep.Next>
                              <FlowStep x:Name="__ReferenceID4">
                                <sap:WorkflowViewStateService.ViewState>
                                  <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                                    <av:Point x:Key="ShapeLocation">200,789</av:Point>
                                    <av:Size x:Key="ShapeSize">200,22</av:Size>
                                    <av:PointCollection x:Key="ConnectorLocation">300,811 300,839</av:PointCollection>
                                  </scg5:Dictionary>
                                </sap:WorkflowViewStateService.ViewState>
                                <local:PrepareToSendAdoptedEvent AdoptedEvent="[AdoptedEventMessage]" Destinations="[AdoptedEventDestinations]" sap:VirtualizedContainerService.HintSize="200,22" ServiceIdentifier="[ServiceIdentifier]" ServiceInstanceIdentifier="[ServiceInstanceIdentifier]" />
                                <FlowStep.Next>
                                  <FlowStep x:Name="__ReferenceID5">
                                    <sap:WorkflowViewStateService.ViewState>
                                      <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                                        <av:Point x:Key="ShapeLocation">200,839</av:Point>
                                        <av:Size x:Key="ShapeSize">200,22</av:Size>
                                      </scg5:Dictionary>
                                    </sap:WorkflowViewStateService.ViewState>
                                    <rwa:SendMessage x:TypeArguments="rmea:ServiceAdopted" CorrelateWithCurrentWorkflowInstance="True" Destinations="[AdoptedEventDestinations]" DisplayName="Send ServiceAdopted Event" sap:VirtualizedContainerService.HintSize="200,22" MessageToSend="[AdoptedEventMessage]" />
                                  </FlowStep>
                                </FlowStep.Next>
                              </FlowStep>
                            </FlowStep.Next>
                          </FlowStep>
                        </FlowDecision.True>
                        <FlowDecision.False>
                          <FlowStep x:Name="__ReferenceID8">
                            <sap:WorkflowViewStateService.ViewState>
                              <scg5:Dictionary x:TypeArguments="x:String, x:Object">
                                <av:Point x:Key="ShapeLocation">330,619</av:Point>
                                <av:Size x:Key="ShapeSize">200,22</av:Size>
                                <av:PointCollection x:Key="ConnectorLocation">430,641 430,720 400,720</av:PointCollection>
                              </scg5:Dictionary>
                            </sap:WorkflowViewStateService.ViewState>
                            <local:InstallAsWindowsService sap:VirtualizedContainerService.HintSize="200,22" ServiceExecutablePath="[ServiceExecutablePath]" ServiceIdentifier="[ServiceIdentifier]" />
                            <FlowStep.Next>
                              <x:Reference>__ReferenceID0</x:Reference>
                            </FlowStep.Next>
                          </FlowStep>
                        </FlowDecision.False>
                      </FlowDecision>
                    </FlowStep.Next>
                  </FlowStep>
                </FlowStep.Next>
              </FlowStep>
            </FlowDecision.True>
            <FlowDecision.False>
              <x:Reference>__ReferenceID1</x:Reference>
            </FlowDecision.False>
          </FlowDecision>
        </FlowStep.Next>
      </FlowStep>
    </Flowchart.StartNode>
    <x:Reference>__ReferenceID2</x:Reference>
    <x:Reference>__ReferenceID1</x:Reference>
    <x:Reference>__ReferenceID3</x:Reference>
    <x:Reference>__ReferenceID4</x:Reference>
    <x:Reference>__ReferenceID5</x:Reference>
    <x:Reference>__ReferenceID6</x:Reference>
    <x:Reference>__ReferenceID7</x:Reference>
    <x:Reference>__ReferenceID0</x:Reference>
    <x:Reference>__ReferenceID8</x:Reference>
  </Flowchart>
</Activity>